/**
 * 0203
 *
 * @Author : Ruoyu Wang
 * @DateTime : 2024/8/13 20:49
 */

#include <iostream>
#include <vector>

using namespace std;

struct ListNode {
    int val;
    ListNode *next;

    ListNode() : val(0), next(nullptr) {}

    ListNode(int x) : val(x), next(nullptr) {}

    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

class Solution {
public:
    ListNode *removeElements(ListNode *head, int val) {
        ListNode *h = new ListNode(-1, head);
        ListNode *p = h;
        while (p->next != nullptr) {
            if (p->next->val == val) {
                p->next = p->next->next;
                continue;
            }
            p = p->next;
        }
        return h->next;
    }
};

int main() {

    return 0;
}